<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%@ include file="/common/message.jsp"%>
<%@ include file="/common/user.jsp"%>
<%
    // 退出日程
    String id = input.getDesc("id", "-1");
    List<Arrangement> list = QBuilder.db("basedb").select().from("Arrangement").where(new Where("hospital=", hospital).and("status=", STATUS_ENABLE).and("id=", id).and("partner=", token.getUid())).query().getResultObj();
    if (isEmpty(list)) {
        msg = new Message(30041, "暂无日程");
        msg.put("data", new ArrayList());
        Tools.encryptPrint(out, msg);
        return;
    }
    Arrangement ag = list.get(0);
    ag.setStatus(STATUS_DISABLE);
    DBTools.db("basedb").modItem(ag, ag.getId());
    Information info = new Information();
    info.setOid(ag.getId()+"");
    info.setHospital(ag.getHospital());
    info.setTitle("日程通知");
    info.setSumary("日程");
    info.setCategory(4);
    List<Integer> uids = new ArrayList<Integer>();
    uids.add(ag.getUid());
    uids.add(ag.getPartner());
    Map<Integer, User> users = usersByUids(uids);
    User user =  users.get(ag.getUid());
    String author = user.getName();
    user =  users.get(ag.getPartner());
    String joiner = user.getName();
    info.setContent(author + "您好, "+joiner+"退出了日程。\n内容:"+ag.getTitle()+"\n日期:"+ag.getStart());
    createMsg(info, ag.getUid());
    Tools.encryptPrint(out, msg);
%>
